package com.isunland.managesystem.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BasePagerActivity;
import com.isunland.managesystem.entity.CustomerMainOriginal;
import com.isunland.managesystem.entity.CustomerNeed;

public class CustomerPagerActivity extends BasePagerActivity {
  @SuppressWarnings("unused") private static final String TAG = "CustomerPagerActivity";
  protected static final String EXTRA_TAB = "com.isunland.managesystem.extra_tab";
  protected static final String EXTRA_CUSTOMER_NEED =
      "com.isunland.managesystem.EXTRA_CUSTOMER_NEED";
  protected static final int VALUE_CUSTOMER_NEED = 0;
  protected static final int VALUE_CUSTOMER_CONTACT = 1;
  private CustomerNeedFragment mCustomerNeedFragment;
  private CustomerContactListFragment mCustomerContactListFragment;
  private int[] mTitleId = {
      R.string.customer_need, R.string.customer_contact
  };
  private CustomerNeed mCustomerNeed;
  private int mType;
  private CustomerMainOriginal.rCustomerMain mCustomerDetail;

  @Override protected void onCreate(Bundle arg0) {
    mCustomerNeed =
        (CustomerNeed) getIntent().getSerializableExtra(CustomerNeedFragment.EXTRA_CUSTOMER_NEED);
    mType = getIntent().getIntExtra(CustomerNeedFragment.EXTRA_TYPE, 0);
    mCustomerDetail = (CustomerMainOriginal.rCustomerMain) getIntent().getSerializableExtra(
        CustomerNeedFragment.CUSTOMERMAIN);
    super.onCreate(arg0);
  }

  @Override protected Fragment createFragmentOne() {
    mCustomerNeedFragment = CustomerNeedFragment.newInstance(mCustomerNeed, mType, mCustomerDetail);
    return mCustomerNeedFragment;
  }

  @Override protected Fragment createFragmentTwo() {
    mCustomerContactListFragment = CustomerContactListFragment.newInstance(mCustomerNeed);
    return mCustomerContactListFragment;
  }

  @Override protected int[] createTitle() {
    return mTitleId;
  }

  @Override public int currentTab() {
    return getIntent().getIntExtra(EXTRA_TAB, VALUE_CUSTOMER_NEED);
  }
}
